package com.liangtian.mdm.dm.common.page;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.liangtian.mdm.dm.common.enums.Flag;

/**
 * 对fastjson的二次封装
 *
 * @author honye
 */
public class JsonWrap {

    /**
     * 通过给定的值过滤器，来转换标识符字符按
     *
     * @param data
     * @return
     */
    public static String toJSONString(Object data) {

        ValueFilter vf = new ValueFilter() {
            @Override
            public Object process(Object object, String propertyName, Object propertyValue) {
                return Flag.toDesc(propertyValue, propertyName);
            }
        };

        return JSON.toJSONString(data, vf);
    }

}
